import moduleRegist from '@/utils/moduleRegist';
// import { module as orderpayerModule } from './module/module';
// import { module as taxpayerItemsModule } from '../taxpayerItems/module';

import { module as orderBlanketModule } from './module/blanketModule';
import { module as orderChildModule } from './module/childModule';
import { module as orderRefundModule } from './module/refundModule';
import { module as echartModule } from './module/echartModule';
import statement from "../statement/routes";
// 报表管理
import qr from './qr/routes';

const BlanketOrder = resolve => {
  require(['./BlanketOrder'], resolve);
};

const Layout = resolve => {
  require(['./Layout'], resolve);
};

const ChildOrder = resolve => {
  require(['./ChildOrder'], resolve);
};

const RefundOrder = resolve => {
  require(['./RefundOrder'], resolve);
};

const DataStatistics = resolve => {
  require(['./DataStatistics'], resolve);
};

const BlanketOrderDetailForm = resolve => {
  require(['./BlanketOrderDetailForm'], resolve);
};

const ChildOrderDetailForm = resolve => {
  require(['./ChildOrderDetailForm'], resolve);
};

const RefundOrderDetailForm = resolve => {
  require(['./RefundOrderDetailForm'], resolve);
};

export default [
  /** 配置管理路由 */
  {
    path: 'orderCenter',
    redirect: 'orderCenter/dataStatistics',
    component: Layout,
    meta: {
      title: '订单中心',
      name: '订单中心',
      permission: 'trade:order',
      componentName: 'OrderpayerLayout',
      keepAlive: true,
      icon: 'md-people',
      show: false
    },
    beforeEnter: (to, from, next) => {
    /* eslint-disable */
      moduleRegist(orderBlanketModule);
      moduleRegist(orderChildModule);
      moduleRegist(orderRefundModule);
      moduleRegist(echartModule);
      next()
     //   moduleRegist(orderpayerModule);
      //moduleRegist(taxpayerItemsModule);
    },
    children: [
      {
        path: 'dataStatistics',
        component: DataStatistics,
        meta: {
          title: '数据统计',
          name: '数据统计',
          breadcrumb: '数据统计',
          permission: 'trade:order:statistics',
          show: true,
          keepAlive: true,
          componentName: 'OrderpayerAddView',
          icon: ''
        }
      },
      {
        path: 'blanketOrder',
        component: BlanketOrder,
        meta: {
          title: '订单列表',
          name: '总订单查询',
          breadcrumb: '订单列表',
          permission: 'trade:order:blanketOrder',
          keepAlive: true,
          componentName: 'OrderpayerListView',
          icon: ''
        }
      },
      {
        path: 'blanketOrderDetailForm',
        component: BlanketOrderDetailForm,
        meta: {
          title: '总订单详情',
          name: '总订单详情',
          breadcrumb: '总订单详情',
          permission: 'trade:order:blanketOrderDetailForm',
          keepAlive: true,
          show: false,
          componentName: 'OrderpayerListView',
          icon: ''
        }
      },
      {
        path: 'childOrderDetailForm',
        component: ChildOrderDetailForm,
        meta: {
          title: '子订单详情',
          name: '子订单详情',
          breadcrumb: '子订单详情',
          permission: 'trade:order:childOrder:childOrderDetailForm',
          keepAlive: true,
          show: false,
          componentName: 'OrderpayerListView',
          icon: ''
        }
      },
      {
        path: 'refundOrderDetailForm',
        component: RefundOrderDetailForm,
        meta: {
          title: '退款订单详情',
          name: '退款订单详情',
          breadcrumb: '退款订单详情',
          permission: 'trade:order:refundOrder:refundOrderDetailForm',
          keepAlive: true,
          show: false,
          componentName: 'OrderpayerListView',
          icon: ''
        }
      },
      {
        path: 'childOrder',
        component: ChildOrder,
        meta: {
          title: '子订单查询',
          name: '子订单查询',
          breadcrumb: '子订单查询',
          permission: 'trade:order:childOrder',
          show: true,
          keepAlive: true,
          componentName: 'OrderpayerAddView',
          icon: ''
        }
      },
      {
        path: 'refundOrder',
        component: RefundOrder,
        meta: {
          title: '退款订单查询',
          name: '退款订单查询',
          breadcrumb: '退款订单查询',
          permission: 'trade:order:refundOrder',
          show: true,
          keepAlive: true,
          componentName: 'OrderpayerDetailView',
          icon: ''
        }
      },
      {
        path: '/qr',
        component: Layout,
        meta: {
          title: '二维码',
          name: '二维码',
          permission: 'trade:order:qr',
          icon: 'md-analytics',
          show: true
        },
        children: [...qr]
      },
      {
        path: 'orderBill',
        component: () => import('./other/orderbill'),
        meta: {
          title: '账单管理',
          name: '账单管理',
          breadcrumb: '账单管理',
          permission: 'trade:order:bill',
          show: true,
          keepAlive: false,
          componentName: 'OrderBill',
          icon: ''
        }
      },
    ]
  }
];
